/***************************************************************************
 *   Copyright (C) 2007 by Ivan Vasić                                      *
 *   ivasic@gmail.com                                                      *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#ifndef MODEL_H
#define MODEL_H

#include <QObject>

class QString;

/**
 * @class Model
 * @brief Interfejs za kreiranje modela tipa Torrent i User
 * @author Ivan Vasić <ivasic@gmail.com>
*/
class Model : public QObject
{
		Q_OBJECT
	public:
		
		/**
		 * @brief Default konstruktor
		 * @param id QString naziv identifikacionog unique parametra objekta (Za torrent je to 'Name' zbog prikaza, a za user-a je username)
		 * @param modelTypeName je tekstualna reprezentacija tipa objekta (Torrent ili User)
		 * @param parent QObject* roditelj
		 */
		Model(const QString id, const QString modelTypeName, QObject *parent = 0);
		~Model();

		///Accessor za m_modelTypeName
		const QString& modelTypeName() const { return m_modelTypeName; }
		
		///Set metod za m_id
		void setId(const QString& val)  { m_id = val; }
		///Get metod za m_id
		const QString& id() const  { return m_id; }
		
		///Vraca TRUE ukoliko je objekat ispravno konstruisan i sadrzi validne podatke iz baze
		bool isValid() const { return m_isValid; }
				
		///Update vrsi azuriranje podataka koje sadrzi ovaj objekat.
		virtual void update() = 0;		
		
		///Vraca listu properties parametara za ovaj objekat.
		virtual QStringList getPropertiesMap() const = 0;
					
		///Brise podatke o ovom objektu u bazi podataka.
		virtual void remove() = 0;

	private:

		///Identification field value. ('Name' for Torrent and 'username' for User).
		QString m_id;

		///Tekstualna reprezentacija tipa objekta (Torrent ili User)
		QString m_modelTypeName;
		
	protected:		
		///Da li ima validne podatke ili ne (u slucaju da je trazen model za nepostojeci ID i sl.)
		bool m_isValid;



};

#endif
